package com.xuecheng.media.service;

import com.xuecheng.base.model.PageParams;
import com.xuecheng.base.model.PageResult;
import com.xuecheng.media.model.dto.QueryMediaParamsDto;
import com.xuecheng.base.model.RestResponse;
import com.xuecheng.media.model.dto.UploadFileParamsDto;
import com.xuecheng.media.model.dto.UploadFileResultDto;
import com.xuecheng.media.model.po.MediaFiles;

import java.io.File;

/**
 * @description 媒资文件管理业务类
 * @author Mr.M
 * @date 2022/9/10 8:55
 * @version 1.0
 */
public interface MediaFileService {

     /**
      * @description 媒资文件查询方法
      * @param pageParams 分页参数
      * @param queryMediaParamsDto 查询条件
      * @return com.xuecheng.base.model.PageResult<com.xuecheng.media.model.po.MediaFiles>
      * @author Mr.M
      * @date 2022/9/10 8:57
     */
     public PageResult<MediaFiles> queryMediaFiles(Long companyId,PageParams pageParams, QueryMediaParamsDto queryMediaParamsDto);

     public UploadFileResultDto uploadFile(Long companyId ,UploadFileParamsDto uploadFileParamsDto,String localFilePath ,String objectName);
     /**
      * @description 将文件信息添加到文件表
      * @param companyId  机构id
      * @param fileMd5  文件md5值
      * @param uploadFileParamsDto  上传文件的信息
      * @param bucket  桶
      * @param objectName 对象名称
      * @return com.xuecheng.media.model.po.MediaFiles
      * @author Mr.M
      * @date 2022/10/12 21:22
      */

     public MediaFiles addMediaFilesToDb(Long companyId,String fileMd5,UploadFileParamsDto uploadFileParamsDto,String bucket,String objectName);

     public RestResponse<Boolean> checkChunk(String fileMd5,int chunkIndex);

     public RestResponse<Boolean> checkFile(String fileMd5);

     public RestResponse<Boolean> uploadChunk(String fileMd5,int chunkIndex,String localChunkPath);

     public RestResponse  mergeChunks(Long companyId,String fileMd5,int chunkTotal, UploadFileParamsDto uploadFileParamsDto);

     public File downloadFileFromMinIO(String bucket, String objectName);


     public boolean addMediaFilesToMinIO(String localFilePath,String mimeType,String bucket, String objectName);

     public MediaFiles getFileById(String mediaId);
}
